import abscmdaction from "./abscmdaction";
import cmdenums from "./cmdenums";
import globalConst from "../../canvas/common/globalConst.js";
var global = globalConst.GlobalConst;

import linedrawaction from "./drawaction/linedrawaction";
import circledrawaction from "./drawaction/circledrawaction";
import rectdrawaction from "./drawaction/rectdrawaction";
import arcdrawaction from "./drawaction/arcdrawaction";
import ellipseaction from "./drawaction/ellipseaction";
import ellipsearcaction from "./drawaction/ellipsearcaction";


class DrawCmdAction extends abscmdaction.ABSCmdAction {
    constructor() {
        super();
    }

    getCurentAction(type) {
        let subaction = null;
        switch (type) {
            case cmdenums.DrawCmdType.line:
                subaction = new linedrawaction.LineDrawAction();
                break;

            case cmdenums.DrawCmdType.circle:
                subaction = new circledrawaction.CircleDrawAction();
                break;

            case cmdenums.DrawCmdType.rect:
                subaction = new rectdrawaction.RectDrawAction();
                break;

            case cmdenums.DrawCmdType.arc:
                subaction = new arcdrawaction.ArcDrawAction();
                break;

            case cmdenums.DrawCmdType.ellipse:
                subaction = new ellipseaction.EllipseDrawAction();
                break;

            case cmdenums.DrawCmdType.ellipseArc:
                subaction = new ellipsearcaction.EllipseArcDrawAction();
                break;
        }

        return subaction;
    }

    getCurentActionByTool(drawTool) {
        let toolKind = drawTool >> 16;
        let subaction = null;
        switch (toolKind) {
            case global.BaseUnitPolyline:
            case global.ConnectLine:
                subaction = new linedrawaction.LineDrawAction();
                break;

            case global.BaseUnitCircle:
                subaction = new circledrawaction.CircleDrawAction();
                break;

            case global.BaseUnitRectangle:
                subaction = new rectdrawaction.RectDrawAction();
                break;

            case global.BaseUnitArc:
                subaction = new arcdrawaction.ArcDrawAction();
                break;

            case global.BaseUnitEllipse:
                subaction = new ellipseaction.EllipseDrawAction();
                break;

            case global.BaseUnitEllipseArc:
                subaction = new ellipsearcaction.EllipseArcDrawAction();
                break;
        }

        return subaction;
    }
}

export default { DrawCmdAction }